using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerAirState : PlayerState
{
    public PlayerAirState(Player player, StateMachine stateMachine, string animName) : base(player, stateMachine, animName)
    {
    }

    public override void Enter()
    {
        base.Enter();
    }

    public override void Exit()
    {
        base.Exit();
    }

    public override void Update()
    {
        base.Update();

        if (Input.GetKeyDown(KeyCode.Mouse0))
            stateMachine.ChangeState(player.primaryAttack);

        if (Input.GetKeyDown(KeyCode.Space) && player.jumpIndex != 2)
        {
            stateMachine.ChangeState(player.jumpState);
        }

        if (entity.IsWallDetected())
            stateMachine.ChangeState(player.wallSlide);

        if (entity.IsGroundDetected())
        {
            stateMachine.ChangeState(player.idleState);
            player.jumpIndex = 0;
        }
            

        if (xInput != 0)
            player.SetVelocity(player.moveSpeed * .8f * xInput, rb.velocity.y);
    }
}
